'use strict';

angular.module('app').controller('registerCtrl', ['$interval','$http','$scope', function($interval,$http,$scope){
	$scope.submit=function(){
		$http.post('data/regist.json',$scope.user).success(function(resp){
			console.log(resp);
		})
	}
	var count=60;
	$scope.send=function(){
		console.log('s');
		$http.get('data/code.json').then(function(resp){
			if(1===resp.data.state){
				count=60;
				console.log('2');
				$scope.time='60s';
				var interval=$interval(function(){
					if(count<=0){
						$interval.cancel(interval);
						$scope.time='';
					}else{
						count--;
						$scope.time=count+'s'
					}
					
				},1000)
			}
		})
	}
}])